#include <boost/thread.hpp>
#include <iostream>

void wait(int seconds)
{
	boost::this_thread::sleep(boost::posix_time::seconds(seconds) );
}

void thread()
{
	std::cout << "Thread ID: " << boost::this_thread::get_id() << std::endl;
	try {
		for (int i=0; i<5; ++i){
			wait(1);
			std::cout << i << std::endl;
		}
	}
	catch (boost::thread_interrupted&)
	{
		std::cout << "interrupted" << std::endl;
	}
}

int main()
{
	boost::thread t(thread);
	std::cout << "Thread ID: " << boost::this_thread::get_id() << std::endl;
	std::cout << "#Physical Thread: " << boost::thread::hardware_concurrency() 
		<< std::endl;
	wait(3);
	t.interrupt();
	t.join();
}